<?php

class Out extends MY_Controller{
	private $status = true;
	private $token = '';
	
	function __construct(){
		parent::__construct();
	}
	
	function _remap($method){
		switch ($method) {
			case 'index':
					echo "No Autorizado ;D";
			break;
			case 'chrome':
					$this->chrome_ext();
			break;
			default:
				echo "No Autorizado ;D";
			break;
		}
	}
	
	function chrome_ext(){
		$res = $this->checkAccessToken();
		
		$this->load->model('user_model');
		$info = $this->user_model->getInfoUser($this->params);
		$this->params['usr_info'] = $info['user'];
		
		if ($res && $this->params['usr_info']['status']==1){
			$this->load->model('publication_model');
			$this->params['result_items_per_page'] 	= 16;
			$this->params['result_page'] 			= 0;
			$publication = $this->publication_model->getPublications($this->params);
			if(is_array($publication['publications'])){
				$publication['status'] = array('code'=>200);
			}
			else{
				$publication['status'] = array('code'=>0);
			}
				echo json_encode($publication);
		}
		else echo false;
	}
}